package edu.ptu.acl.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import edu.ptu.acl.common.ResultVO;
import edu.ptu.acl.entity.Log;
import edu.ptu.acl.service.ILogService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.xml.crypto.Data;
import java.io.IOException;
import java.util.Date;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LinJC
 * @since 2022-03-15
 */
@RestController
@RequestMapping("/log")
public class LogController {

    @Resource
    private ILogService logService;

    @PutMapping("/recover/{id}")
    public ResultVO recover(@PathVariable Long id) throws IOException {
        logService.recover(id);
        return ResultVO.success();
    }

    /***
     * 根据 修改者和时间查找
     * @param
     * @return
     */
    @GetMapping("/getLog/{pageNo}/{pageSize}")
    public ResultVO getLogByCondition(@PathVariable Integer pageNo, @PathVariable Integer pageSize,
                                      String fromTime,String toTime,String updator,String type){
        Page<Log> logPage = new Page<>(pageNo,pageSize);

//        fromTime.replace("+"," ");
//        toTime.replace("+"," ");

        logService.getLogByCondition(logPage,fromTime,toTime,updator,type);
        return ResultVO.success(logPage);
    }
}
